import tkinter as tk
from ..styles.themes import BUTTON_STYLES

def create_animated_button(parent, text, command, style="primary", width=15, height=2):
    def on_enter(event):
        button.config(
            bg=BUTTON_STYLES[style].get("activebackground", BUTTON_STYLES[style]["bg"]),
            relief="sunken"
        )
    
    def on_leave(event):
        button.config(
            bg=BUTTON_STYLES[style]["bg"],
            relief="raised"
        )
    
    def on_click(event):
        button.config(relief="sunken")
        parent.after(100, lambda: button.config(relief="raised"))
        command()
    
    button = tk.Button(
        parent,
        text=text,
        width=width,
        height=height,
        cursor="hand2",
        **BUTTON_STYLES[style]
    )
    
    button.bind("<Enter>", on_enter)
    button.bind("<Leave>", on_leave)
    button.bind("<Button-1>", on_click)
    
    return button

def create_icon_button(parent, text, command, icon_char="★", style="primary"):
    button_text = f" {icon_char} {text} "
    return create_animated_button(parent, button_text, command, style)